#ifndef CONFIG
#define CONFIG

#include "yaml-cpp/yaml.h"

class ConfigManager {
public:
    static std::string GetUAVIP() {
        return GetValue("UAVIP");
    }

    static int GetUAVPort() {
        return std::stoi(GetValue("UAVPORT"));
    }

    static int GetReceiveFromCPort() {
        return std::stoi(GetValue("RECEIVEFROMCPORT"));
    }
    
    static int GetReceiveFromPythonPort() {
        return std::stoi(GetValue("RECEIVEFROMPYTHONPORT"));
    }
    static std::string GetCallbackURL() {
        return GetValue("CALLBACKURL");
    }

    static std::string GetRedisIP() {
        return GetValue("REDISIP");
    }

    static int GetRedisPort() {
        return std::stoi(GetValue("REDISPORT"));
    }

    static std::string GetRedisPassword() {
        return GetValue("REDISPASSWORD");
    }

    static int GetSocketReceiverBufferSize() {
        return std::stoi(GetValue("SOCKETRECEIVERBUFFERSIZE"));
    }

private:
    static std::string GetValue(const std::string& key) {
        YAML::Node config = YAML::LoadFile("./config/config.yaml");
        if (config.IsNull()) {
            throw std::runtime_error("无法加载 YAML 文件！");
        }
        return config[key].as<std::string>();
    }
};

#endif